#!/bin/bash

# 打印logo和描述信息
logo=$(cat <<'EOF'
 _____ _____          __    _____  _____   ____   _____
|_   _|  __ \        / /   |  __ \|  __ \ / __ \ / ____|
  | | | |__) |_   __/ /_   | |  | | |  | | |  | | (___                            | | |  ___/\ \ / / '_ \  | |  | | |  | | |  | |\___ \
 _| |_| |     \ V /| (_) | | |__| | |__| | |__| |____) |
|_____|_|      \_/  \___/  |_____/|_____/ \____/|_____/
                                                                                
         _   _             _
    /\  | | | |           | |                                                      /  \ | |_| |_ __ _  ___| | __
  / /\ \| __| __/ _` |/ __| |/ /
 / ____ \ |_| || (_| | (__|   <
/_/    \_\__|\__\__,_|\___|_|\_\
EOF
)
echo -e "$logo"
echo -e "\033[1;32;40m[*]IPv6 DDoS 攻击是指利用IPv6 协议中的漏洞或错误配置，通过大量的恶意流量向目标网络或服务器发动攻击，以耗尽其带宽、系统资源或服务能力，从而使其无法正常提供服务或导致网络中断。\033[1;37;40m"

# 定义文件字典
declare -A files
files=(
       ["1"]="ddos_cn/ipv6_attack/ICMPv6_Flood.py"
       ["2"]="ddos_cn/ipv6_attack/IPv6_Replay_Attack.py"
       ["3"]="ddos_cn/ipv6_attack/IPv6_Flood_Attack.py"
       ["4"]="ddos_cn/ipv6_attack/IPv6_SLAAC_Flood.py"
       ["5"]="ddos_cn/ipv6_attack/IPv6_Fragmentation_Attack.py"
       ["6"]="ddos_cn/ipv6_attack/Neighbor_Cache_Exhaustion.py"
       ["7"]="ddos_cn/ipv6_attack/IPv6_ND.py"
)

# 使用whiptail创建菜单
while true; do
       choice=$(whiptail --title "IPv6 DDoS 攻击类型" --menu "IPv6 DDoS 攻击是指利用IPv6 协议中的漏洞或错误配置，通过大量的恶意流量向目标网络或服务器发动攻击，以耗尽其带宽、系统资源或服务能力，从而使其无法正常提供服务或导致网络中断。\n\n请选择攻击类型：" 35 78 20 \
       "1" "IPv6 ICMPv6 Flood 攻击" \
       "2" "IPv6 重放攻击" \
       "3" "IPv6 Flood" \
       "4" "IPv6 SLAAC 洪泛攻击" \
       "5" "IPv6 分段攻击" \
       "6" "IPv6 邻居缓存耗尽攻击" \
       "7" "IPv6 邻居发现协议攻击" \
       "0" "返回" \
       3>&1 1>&2 2>&3)

       if [[ $? -eq 0 ]]; then
           if [[ "$choice" == "0" ]]; then
               echo "操作已取消。"
               break
           else
               python3 "${files[$choice]}"
               break
           fi
       else
           echo "操作已取消。"
           break
       fi
done
